package com.qf.service;

import com.qf.mapper.UserMapper;
import com.qf.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 汤奇
 * @version V1.0
 * @Project BookPro
 * @Package com.qf.service
 * @Description:
 * @Date 2022/6/6 18:34
 */
@Service("service1")
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;

//    public UserMapper getUserMapper() {
//        return userMapper;
//    }
//
//    public void setUserMapper(UserMapper userMapper) {
//        this.userMapper = userMapper;
//    }
    @Value("${jdbc.url}")
    private String url;

    @Value("${jdbc.username}")
    private String username;


    @Override
    public List<User> findUserAll() {
        System.out.println("url:"+url);
        System.out.println("username:"+username);
        return userMapper.findUserAll();
    }

    @Override
    @Transactional
    public void updateUser(User user) {
        userMapper.updateUser(user);

        //演示在拥有事务的操作中,如果出现异常, 是否会回滚
        int i = 1/0;
    }
}
